<template>
	<view class="detail">
		<view class="product-wrapper">
			<view class="info-wrapper">
				<image :src="form.productImage" mode="aspectFill" class="product-image"></image>
				<view class="info">
					<view class="title">
						{{ form.productName }}
					</view>
					<view class="number">
						货号：{{ form.productCode }}
					</view>
					<view class="spec-wrapper">
						<!-- <view class="price">
							￥28.8/件
						</view> -->
						<view class="spec">
							毛重{{ form.grossWeight }}斤 净重{{ form.netWeight }}斤
						</view>
					</view>
				</view>
			</view>
			<view class="delivery-quantity">
				<view class="item">
					订货：{{ form.quantity }}件
				</view>
				<view class="item center">
					缺货：{{ form.stockQuantity }}件
				</view>
			</view>
		</view>
		<view class="list-item" v-for="(item,index) in form.detailList" :key="index">
			<view class="item flex">
				客户：{{ item.customerPetName }}
			</view>
			<view class="item">
				分货码：{{ item.sortCode || '-' }}
			</view>
			<view class="item">
				订货：{{ item.quantity }}件
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {}
			}
		},
		onLoad(option) {
			this.getInfo(option.code)
		},
		methods: {
			async getInfo(code) {
				const data = await this.$api.post('/app/supply/record/sortProductDetailList', {
					orderDetailsId: code
				})
				if (data.code === 200) {
					const mainImageVideo = JSON.parse(data.data.mainImageVideo)[0]
					if (mainImageVideo.type === 0) {
						data.data.productImage = mainImageVideo.url + '?imageView2/3/w/300/q/100'
					} else {
						data.data.productImage = mainImageVideo.url + '?vframe/jpg/offset/1'
					}
					this.form = data.data;
				}
			}
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.detail {
		.product-wrapper {
			background-color: #ffffff;
			border-radius: 10upx;
			padding: 20upx;
			margin-top: 2upx;

			.info-wrapper {
				display: flex;

				.product-image {
					width: 140upx;
					height: 140upx;
					min-width: 140upx;
					margin-right: 20upx;
					border-radius: 10upx;
				}

				.info {
					flex: 1;

					.title {
						font-size: 34upx;
						font-weight: bold;
						line-height: 34upx;
						margin-bottom: 20upx;
						text-overflow: -o-ellipsis-lastline;
						overflow: hidden; //溢出内容隐藏
						text-overflow: ellipsis; //文本溢出部分用省略号表示
						display: -webkit-box; //特别显示模式
						-webkit-line-clamp: 1; //行数
						line-clamp: 1;
						-webkit-box-orient: vertical; //盒子中内容竖直排列
					}

					.number {
						font-size: 28upx;
						color: #555555;
						line-height: 28upx;
						margin-bottom: 20upx;
					}

					.spec-wrapper {
						display: flex;
						align-items: center;

						.price {
							font-size: 34upx;
							font-weight: bold;
							color: #FC003B;
							margin-right: 20upx;
						}

						.spec {
							font-size: 28upx;
							color: #555;
						}
					}
				}
			}

			.delivery-quantity {
				display: flex;
				align-items: center;
				padding-top: 20upx;
				margin-top: 20upx;
				border-top: 1upx solid #efefef;

				.item {
					flex: 1;
					font-size: 30upx;

					&.center {
						text-align: center;
					}

					&.right {
						text-align: right;
					}
				}
			}
		}

		.list-item {
			background-color: #ffffff;
			border-radius: 10upx;
			margin: 20upx 20upx 0 20upx;
			padding: 30upx;
			display: flex;
			flex-wrap: wrap;
			align-items: center;

			.item {
				width: 50%;

				&.flex {
					width: 100%;
					margin-bottom: 10rpx;
				}
			}
		}
	}
</style>